#!/usr/bin/python3
# -*- coding: utf-8 -*-

from playwright.sync_api import Page


class Select:
    def __init__(self, page: Page):
        self.page = page

    def get_by_label_option_value(self, label_name, value):
        """通过指定值定位"""
        return self.page.get_by_label(label_name).select_option(value=value)

    def get_by_label_option_index(self, label_name, index):
        """通过索引定位"""
        return self.page.get_by_label(label_name).select_option(index=index)

    def get_by_label_option_label(self, label_name, label):
        """通过 html lable定位"""
        return self.page.get_by_label(label_name).select_option(label=label)

    def select_option(self, select_option, value):
        """
        通过 page对象直接调用
        :param select_option: select#project
        :param value: 值
        :return:
        """
        return self.page.select_option(select_option, value)
